package com.umeox.iqibla.qimi_app

import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.ImageView
import androidx.viewpager2.widget.ViewPager2
import com.umeox.iqibla.qimi_app.adapter.WelcomeImageAdapter
import com.umeox.moto.watch.themes.app.ThemeAppCompatActivity

class RoleSelectActivity : ThemeAppCompatActivity() {

    private lateinit var viewPager: ViewPager2
    private lateinit var ivLeft: ImageView
    private lateinit var ivRight: ImageView

    private val welcomeImages = listOf(
//        R.drawable.ic_boy,
        R.drawable.ic_gril,
    )

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_role_select)
        
        initViews()
        setupViewPager()
    }

    private fun initViews() {
        viewPager = findViewById(R.id.viewPager)
        ivLeft = findViewById(R.id.ivLeft)
        ivRight = findViewById(R.id.ivRight)
        ivLeft.visibility = View.GONE
        ivRight.visibility = View.GONE

        ivLeft.setOnClickListener {
            viewPager.setCurrentItem(0,true)
        }
        ivRight.setOnClickListener {
            viewPager.setCurrentItem(1,true)
        }

    }

    private fun setupViewPager() {
        val adapter = WelcomeImageAdapter(welcomeImages)
        viewPager.adapter = adapter
        adapter.onItemClick = { _ ->
            val intent = Intent(this, ChatActivity::class.java)
            intent.putExtra("agentId", BuildConfig.GRIL_AGENT_ID)
            startActivity(intent)
        }
//        viewPager.registerOnPageChangeCallback(object :ViewPager2.OnPageChangeCallback() {
//
//            override fun onPageSelected(position: Int) {
//                super.onPageSelected(position)
//                if (position == 0) {
//                    if (ThemeManager.getInstance().currentTheme == 0) {
//                        //暗色
//                        ivLeft.drawable.mutate().setTint("#4DFFFFFF".toColorInt())
//                        ivLeft.isEnabled = false
//                        ivLeft.visibility = View.INVISIBLE
//                        ivRight.drawable.mutate().setTint("#FFFFFF".toColorInt())
//                        ivRight.isEnabled = true
//                        ivRight.visibility = View.VISIBLE
//                    } else {
//                        //亮色
//                        ivLeft.drawable.mutate().setTint("#4D000000".toColorInt())
//                        ivLeft.isEnabled = false
//                        ivLeft.visibility = View.INVISIBLE
//                        ivRight.drawable.mutate().setTint("#000000".toColorInt())
//                        ivRight.isEnabled = true
//                        ivRight.visibility = View.VISIBLE
//                    }
//
//                } else {
//                    if (ThemeManager.getInstance().currentTheme == 0) {
//                        //暗色
//                        ivLeft.drawable.mutate().setTint("#FFFFFF".toColorInt())
//                        ivLeft.isEnabled = true
//                        ivLeft.visibility = View.VISIBLE
//                        ivRight.drawable.mutate().setTint("#4DFFFFFF".toColorInt())
//                        ivRight.isEnabled = false
//                        ivRight.visibility = View.INVISIBLE
//                    } else {
//                        //亮色
//                        ivLeft.drawable.mutate().setTint("#000000".toColorInt())
//                        ivLeft.isEnabled = true
//                        ivLeft.visibility = View.VISIBLE
//                        ivRight.drawable.mutate().setTint("#4D000000".toColorInt())
//                        ivRight.isEnabled = false
//                        ivRight.visibility = View.INVISIBLE
//                    }
//                }
//            }
//        })
    }
} 